import { Component, ViewChild } from '@angular/core';

import { Storage } from '@ionic/storage';

import { DomSanitizer } from '@angular/platform-browser';

import { Events, AlertController, App, ModalController, NavController, NavParams, ActionSheetController, Content } from 'ionic-angular';

import { IrpReportOutsideListService } from './list.service';

import { Config } from '../../../../../providers/config';

import { IrpReportOutsideDetailPage } from '../detail/detail.component';
import { Common } from '../../../../../providers/common';



import _ from 'lodash';

@Component({
  selector: 'page-irp-report-outside-list-list',
  templateUrl: './list.html',
  providers: [IrpReportOutsideListService]
})
export class IrpReportOutsideListPage {


  public ListData:any =[] ;


  showInfinite = false;

  constructor(
    public alertCtrl: AlertController,
    public app: App,
    public modalCtrl: ModalController,
    public navCtrl: NavController,
    public listService: IrpReportOutsideListService,
    private navParams: NavParams,
    public events: Events,
    public storage: Storage,
    private sanitizer: DomSanitizer,
    public actionSheetCtrl: ActionSheetController,
    public common :Common
  ) {

    this.getList()

  }

  //获取列表数据
  getList(){
    this.listService.getListData().subscribe(
      data =>{
        console.log(data)
        this.ListData = data;
      }
    )

  }




  getListData(item){
    this.navCtrl.push(IrpReportOutsideDetailPage, item);
  }

  //下拉刷新
doRefresh(refresher){
    this.getList();

    setTimeout(() => {
    refresher.complete();
    }, 1000);

  }
//上拉加载
doInfinite(infiniteScroll){
  console.log(infiniteScroll)
  this.ListData.push(
  {
  'title' : '文化部召开艺术家学习贯彻党的十九大精神座谈会',
  'reportKind':'公告点评' ,
  'author':'谢小姐',
  'industry':'海大集团',
  'Grade':'超配',
  'date': this.common.getTime(0)
  }
  )
    setTimeout(() => {
    infiniteScroll.complete();

  },1000);
}


}
